package Java7_Concurrency_Cookbook.thread_synchronized_helper.cyclic_barrier;

/**
 * 各个Searcher线程执行完成之后, Grouper线程开始运行
 * @author lixiangke
 */
public class Grouper implements Runnable {

    private Results results;

    public Grouper(Results results) {
        this.results = results;
    }

    @Override
    public void run() {
        int finalResult = 0;
        System.out.println("Grouper : Processing results");
        int data[] = results.getData();
        for (int number : data) {
            finalResult += number;
        }
        System.out.println("Grouper : Total result : " + finalResult);
    }
}
